<?php
	namespace Common\Logic;
	use Common\Model\ClassRoomModel;
	class ClassRoomLogic extends ClassRoomModel{
		/*
		* Function:		getClassRoomList
		* Description:	教室列表
		* @param:		$page string 起始页
						$filter array 过滤数组
						$pageSize string 每页显示条数
		*/
		public function getClassRoomList($page=1,$filter = '',$pageSize=20){
			$conditon = $this->getClassRoomFilter($filter);
			return $this->where($conditon)->order('sort desc,id desc')->limit(($page-1)*$pageSize,$pageSize)->select();
		}
		
		/*
		* Function:get:	getClassRoomFilter
		* Description:	教室列表搜索过滤项
		* @param:		$filter array 过滤数组
		*/
		public function getClassRoomFilter($filter = ''){
			$conditon = array();
			$conditon['is_deleted'] = 0;
			if(!empty($filter['title'])){
				$conditon['name'] = array('like','%'.$filter['title'].'%');
			}
			if(!empty($filter['store_id'])){
			    $conditon['store_id'] = $filter['store_id'];
			}
			return $conditon;
		}
		
		/*
		* Function:get:	getClassRoomCount
		* Description:	教室列表总数
		* @param:		$filter array 过滤数组
		*/
		public function getClassRoomCount($filter = ''){
			$conditon = $this->getClassRoomFilter($filter);
			return $this->where($conditon)->count();
		}
		
		/*
		* Function:		addClassRoom
		* Description:	增加教室
		* @param:		$data array 增加的数组
		*/
		public function addClassRoom($data){
			return $this->add($data);
		}
		
		/*
		* Function:		getClassRoomInfo
		* Description:	获取教室信息 by row
		* @param:		$id int ID
		*/
		public function getClassRoomInfo($id){
			return $this->where(array('id'=>$id))->find();
		}
		
		/*
		* Function:		updateClassRoom
		* Description:	更新教室
		* @param:		$data array 更新的数组
		*/
		public function updateClassRoom($data){
			return $this->save($data);
		}
		
		/*
		* Function:		deleteClassRoom
		* Description:	删除教室
		* @param:		$id int ID
		*/
		public function deleteClassRoom($id){
			return $this->where(array('id'=>$id))->delete();
		}
		
		/*
		* Function:		getClassRoomAllList
		* Description:	部门列表
		*/
		public function getClassRoomAllList(){
			return $this->where(array('status'=>1))->select();
		}
	}
?>